package top.majuan.springboot3.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import top.majuan.springboot3.base.PageBean;
import top.majuan.springboot3.base.R;
import top.majuan.springboot3.entity.TbSoftware;
import top.majuan.springboot3.entity.TbStudent;
import top.majuan.springboot3.service.TbSoftwareService;
import top.majuan.springboot3.vo.PageVo;

@RestController
@RequiredArgsConstructor
@RequestMapping("/software")
public class TbSoftwareController {
    public final TbSoftwareService tbSoftwareService;

    @PostMapping("")
    public R<String> insert(@RequestBody TbSoftware tbSoftware) {
        return tbSoftwareService.insert(tbSoftware);
    }

    @GetMapping("/{pn}/{ps}")
    public R<PageVo<TbSoftware>> query(@PathVariable("pn") Long pageNumber, @PathVariable("ps") Long pageSize, TbSoftware tbSoftware) {
        return tbSoftwareService.query(tbSoftware, PageBean.instance(pageNumber,pageSize));
    }

    @GetMapping("/{id}")
    public R<TbSoftware> queryByKey(@PathVariable("id") Integer id) {
        return tbSoftwareService.queryByKey(id);
    }

    @PutMapping("")
    public R<String> update(@RequestBody TbSoftware tbSoftware) {
        return tbSoftwareService.update(tbSoftware);
    }

    @DeleteMapping("/{id}")
    public R<String> delete(@PathVariable("id") Integer id) {
        return tbSoftwareService.delete(id);
    }
}
